<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: news_ticker.php 71 2013-09-21 12:00:32Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 71 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:00:32 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require ('includes/application_top.php');

$languages = get_languages();

if(isset($_GET['l']) && isset($_GET['id'])) {
	$db->db_query("DELETE FROM ".TABLE_NEWS_TICKER." WHERE id = '".$_GET['id']."' AND language_id = '".$_GET['l']."' ");
	redirect(href_link(FILENAME_NEWS_TICKER, '#language_'.$_GET['l']));
}

if(isset($_POST['action']) && ($_POST['action'] == 'save' )) {

	$text_post = $db->db_prepare($_POST['ticker_text']);

	if($_POST['new_ticker_text'][$_POST['l']] !='')
		$db->db_query("INSERT INTO ".TABLE_NEWS_TICKER." VALUES (NULL, '". trim($_POST['new_ticker_text'][$_POST['l']])."', '".$_POST['l']."', '1') ");

	foreach($text_post AS $lang => $tmp)
		foreach($tmp AS $id => $text)
			$db->db_query("UPDATE ".TABLE_NEWS_TICKER." SET ticker_text = '".$text."' WHERE id = '".$id."' AND language_id = '".$lang."' ");

	redirect(href_link(FILENAME_NEWS_TICKER, '#language_'.$_POST['l']));
}
require(DIR_WS_INCLUDES.'metatag.php'); 
?>
<script type="text/javascript">
	$(function(){$('#tabs').tabs({fx:{opacity:'toggle'}});});
</script>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
	<table class="outerTable">
		<tr>
			<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
				<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
			</td>
		    <td class="boxCenter" valign="top">
		      <table border="0" width="100%" cellspacing="0" cellpadding="0">
		      	<tr>
		      		<td colspan="3">
		      			<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
					    <tr>
					     <td class="pageHeading">
					        News Ticker
					     </td>
					   </tr>
					   </table>
					   Hinweis: jede Sprache muss für sich gespeichert werden.<br /><br />
		      		</td>
		      	</tr>
		        <tr>
		        <td align="left">
		        <div id="tabs">
	  				<ul>
	  					<?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
					    	<li><a href="#language_<?php echo $languages[$i]['id']; ?>">
					    		<span><img src="../lang/<?php echo $languages[$i]['directory'].'/'.$languages[$i]['image']; ?>" alt="" /> <?php echo $languages[$i]['name'] ?></span>
					    	</a></li>
					    <?php } ?>
	  				</ul>

			        <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
			        	<div id="language_<?php echo $languages[$i]['id']; ?>">
							<?php echo draw_form('new_ticker_text', FILENAME_NEWS_TICKER, '', 'post', ''); ?>
				        		<table class="dataTable" width="100%">
					        		<tr class="dataTableHeadingRow">
				                    	<th class="dataTableHeadingContent" height="20" width="30">&nbsp;</th>
				                        <th class="dataTableHeadingContent" height="20" colspan="2">Ticker Text</th>
				                    </tr>
				        			<?php
										$pl = $db->db_query("SELECT id, ticker_text FROM ".TABLE_NEWS_TICKER." WHERE language_id = '".$languages[$i]['id']."' ORDER BY id ASC ");
										if($pl->_numOfRows > 0) {
											$w = 1;
											while(!$pl->EOF) { ?>
											<tr>
												<td align="center">
													<?php echo $w; ?>
												</td>
												<td>
													<?php
														echo draw_input_field('ticker_text['.$languages[$i]['id'].']['.$pl->fields['id'].']', $pl->fields['ticker_text'],'style="width:100%"');
													?>
												</td>
												<td width="1" align="right">
													<a href="<?php echo href_link('news_ticker.php', 'l='.$languages[$i]['id'].'&id='.$pl->fields['id']); ?>" title="diesen Eintrag l&ouml;schen"><img src="images/cross.gif" alt="" /></a>
												</td>
											</tr>
											<?php
											$w++;
											$pl->MoveNext();
											}
										} ?>
									<tr>
										<td valign="top" align="center">neu</td>
										<td colspan="2">
										<?php
											echo draw_input_field('new_ticker_text['.$languages[$i]['id'].']', $pl->fields['ticker_text'],'style="width:100%"')
												.draw_hidden_field('action','save')
												.draw_hidden_field('l', $languages[$i]['id'])
												.'<button type="submit" class="button">'.BUTTON_SAVE.'</button>';
										?>
										</td>
									</tr>
				        		</table>
							</form>
			        	</div>
		        	<?php } ?>
		        	</div>
		        </td>
		        </tr>
			</table>
		</td>
	</tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>